"""
配置文件
包含应用的各种配置参数和常量
"""

from typing import Dict, List, Tuple


class AppConfig:
    """应用配置类"""
    
    # 窗口配置
    WINDOW_WIDTH = 800
    WINDOW_HEIGHT = 600
    WINDOW_MIN_WIDTH = 600
    WINDOW_MIN_HEIGHT = 400
    
    # 颜色配置
    DEFAULT_COLOR = "#FF0000"
    
    # 常用尺寸配置 (宽度, 高度)
    COMMON_SIZES: Dict[str, Tuple[int, int]] = {
        "16:9": [
            (1920, 1080),   # Full HD
            (1280, 720),    # HD
            (2560, 1440),   # 2K
            (3840, 2160),   # 4K
        ],
        "4:3": [
            (1600, 1200),
            (1024, 768),
            (800, 600),
        ],
        "1:1": [
            (1080, 1080),   # Instagram
            (512, 512),     # Icon
            (1024, 1024),   # HD Icon
        ],
        "3:4": [
            (1080, 1440),   # 手机竖屏
            (720, 960),
        ],
        "9:16": [
            (1080, 1920),   # 手机竖屏Full HD
            (720, 1280),    # 手机竖屏HD
        ]
    }
    
    # 自定义尺寸限制
    MIN_WIDTH = 1
    MAX_WIDTH = 10000
    MIN_HEIGHT = 1
    MAX_HEIGHT = 10000
    
    # 文件保存配置
    DEFAULT_SAVE_DIR = "downloads"
    SUPPORTED_FORMATS = ["PNG", "JPEG", "BMP", "TIFF"]
    DEFAULT_FORMAT = "PNG"
    
    # 预览配置
    PREVIEW_SIZE = (200, 200)
    
    # 错误消息
    ERROR_MESSAGES = {
        "INVALID_COLOR": "请输入有效的16进制颜色值（如#FF0000）",
        "INVALID_SIZE": "请输入有效的尺寸值",
        "SAVE_ERROR": "保存文件失败",
        "NETWORK_ERROR": "网络错误",
    }
    
    # 成功消息
    SUCCESS_MESSAGES = {
        "DOWNLOAD_SUCCESS": "图片下载成功！",
    }
    
    @classmethod
    def get_all_common_sizes(cls) -> List[Tuple[str, int, int]]:
        """
        获取所有常用尺寸的列表
        
        Returns:
            List[Tuple[str, int, int]]: (比例名称, 宽度, 高度) 的列表
        """
        sizes = []
        for ratio, dimensions in cls.COMMON_SIZES.items():
            for width, height in dimensions:
                sizes.append((ratio, width, height))
        return sizes